import React from 'react';
import DOMPurify from 'dompurify';


const DangerousInnerHtml = (props) => {

    let purifyRules = {
        ALLOWED_TAGS: ['b', 'i', 'u', 'p', 'br', 'font', 'li', 'ul']
    }


    if(props.includeLink){
        purifyRules = {
            ADD_DATA_URI_TAGS: ['a'],
            ADD_ATTR: ['target']
        }
    }

    const cleanHtml = DOMPurify.sanitize(props.html, purifyRules);
    
    let TagName = "div";
    if (props.tagname){
        TagName = props.tagname;
    }

    return <TagName dangerouslySetInnerHTML={{ __html: cleanHtml}} style={props.style}/>

    
}

export default DangerousInnerHtml;